package com.douban.book.bean;

/**
 * Created by Administrator on 2018/2/28.
 */
public class Book implements Comparable<Book>{



    private String bookName;
    private float score;
    private int personNum;
    private String author;
    private String publish;
    private String publishDate;
    private String price;


    public Book(String bookName, float score, int personNum, String author, String publish, String publishDate, String price) {
        this.bookName = bookName;
        this.score = score;
        this.personNum = personNum;
        this.author = author;
        this.publish = publish;
        this.publishDate = publishDate;
        this.price = price;
    }

    
    @Override
	public String toString() {
		return "Book [bookName=" + bookName + ", score=" + score + ", personNum=" + personNum + ", author=" + author
				+ ", publish=" + publish + ", publishDate=" + publishDate + ", price=" + price + "]";
	}


	public Book() {
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public float getScore() {
        return score;
    }

    public void setScore(float score) {
        this.score = score;
    }

    public int getPersonNum() {
        return personNum;
    }

    public void setPersonNum(int personNum) {
        this.personNum = personNum;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPublish() {
        return publish;
    }

    public void setPublish(String publish) {
        this.publish = publish;
    }

    public String getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(String publishDate) {
        this.publishDate = publishDate;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }


	/*@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((author == null) ? 0 : author.hashCode());
		result = prime * result + ((bookName == null) ? 0 : bookName.hashCode());
		result = prime * result + personNum;
		result = prime * result + ((price == null) ? 0 : price.hashCode());
		result = prime * result + ((publish == null) ? 0 : publish.hashCode());
		result = prime * result + ((publishDate == null) ? 0 : publishDate.hashCode());
		result = prime * result + Float.floatToIntBits(score);
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Book other = (Book) obj;
		if (author == null) {
			if (other.author != null)
				return false;
		} else if (!author.equals(other.author))
			return false;
		if (bookName == null) {
			if (other.bookName != null)
				return false;
		} else if (!bookName.equals(other.bookName))
			return false;
		if (personNum != other.personNum)
			return false;
		if (price == null) {
			if (other.price != null)
				return false;
		} else if (!price.equals(other.price))
			return false;
		if (publish == null) {
			if (other.publish != null)
				return false;
		} else if (!publish.equals(other.publish))
			return false;
		if (publishDate == null) {
			if (other.publishDate != null)
				return false;
		} else if (!publishDate.equals(other.publishDate))
			return false;
		if (Float.floatToIntBits(score) != Float.floatToIntBits(other.score))
			return false;
		return true;
	}
*/
//
	@Override
	public int compareTo(Book book) {
		int flag = 0;
		
		if(this.score>book.score){
			flag=1;
		}
		
		if(this.score<book.score){
			flag=-1;
		}
		
		if(flag==0){
			flag = this.bookName.compareTo(book.bookName);
		}
		return flag;
	}
}